//
//  FUNTLPost.m
//  FuntlFramework
//
//  Created by liweimin on 13-11-13.
//  Copyright (c) 2013年 liweimin. All rights reserved.
//

#import "FUNTLPostRequest.h"

@implementation FUNTLPostRequest

//同步POST请求
+ (NSString *)synPost:(NSString *)strUrl {
    //第一步，创建URL
    NSURL *url = [NSURL URLWithString:strUrl];
    
    //第二步，创建请求
    NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10];
    
    [request setHTTPMethod:@"POST"];//设置请求方式为POST，默认为GET
    
    NSString *str = @"type=focus-c";//设置参数
    NSData *data = [str dataUsingEncoding:NSUTF8StringEncoding];
    [request setHTTPBody:data];
    
    //第三步，连接服务器
    NSData *received = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
    NSString *str1 = [[NSString alloc]initWithData:received encoding:NSUTF8StringEncoding];
    
    return  str1;
}

@end
